#include <iostream>
#include <vector>
#include <stdio.h>
using namespace std;

int removeDuplicates(vector<int>& nums) 
{
    if(nums.size()==0)return 0;
    int i=0,j=1;

    for(;j<nums.size();++j)
    {
        if(nums[j]!=nums[i])
        {
            ++i;
            nums[i]=nums[j];
        }
    }
    return i+1;
}

int main()
{
    std::vector<int> nums = {0,0,1,1,1,2,2,3,3,4};
    std::cout<<removeDuplicates(nums)<<endl;

    for(auto v:nums)
    {
        std::cout<<v<<" ";
    }


    return 0;
}